import { Component,OnInit } from '@angular/core';
// 引入Parse第三方库
import * as Parse from "parse"
(Parse as any).serverURL = "http://metapunk.cn:9999/parse"
Parse.initialize("dev")
@Component({
  selector: 'app-page-home',
  templateUrl: './page-home.component.html',
  styleUrls: ['./page-home.component.scss']
})
export class PageHomeComponent implements OnInit{

//父传子，传给comp-goods组件
ngOnInit():void{
  this.Sort("川菜")
}
// 获取主页面下面的食物简介
foodList:any=[]  
async Sort(item:any){
  console.log(item);
  let query = new Parse.Query("Goods")
  query.limit(9); // 参考：https://docs.parseplatform.org/js/guide/#basic-queries
 
  let list = await query.find()
  this.foodList = list 
}

//子传父，子组件comp-tag-navbar传给父组件
food:any={}
// 如果点击的是套餐推荐以外的内容，则显示相关内容，控制页面显示
showFood:boolean=true
  async addItem(event:string) {
  if(event!='菜品推荐'){
    this.showFood=false
    let query = new Parse.Query("Goods")
    query.equalTo("cate",event) // 参考：https://docs.parseplatform.org/js/guide/#basic-queries
    let list = await query.find()
    this.food = list 
    // console.log(this.food);
    
    // console.log( this.showFood);
  }
  else{
    this.showFood=true
  }
}


}